#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Create by zhang
# Create on 2022/8/6 10:14
import os, sys
from enum import Enum

# __font_path = os.path.abspath(os.path.dirname(__file__))

# 解决pyinstaller打包python程序可执行文件路径问题
if getattr(sys, 'frozen', False):  # 判断是exe还是.py程序
    # __font_path = os.path.dirname(sys.executable)  # exe程序路径
    __font_path = sys._MEIPASS # exe程序路径
elif __file__:
    __font_path = os.path.dirname(__file__)  # .py程序路径


def get_icon_path(key:str):
    icon_path = os.path.join(__font_path, f"{key}.ttf")
    if key is not None and len(key) > 0 and os.path.exists(icon_path):
        return icon_path
    else:
        return os.path.join(__font_path, "SimHei.ttf")


class FontPathEnum(Enum):
    SimHei = get_icon_path("SimHei")
    Arial = get_icon_path("Arial")